
use pamd;

CREATE TABLE [Occupation](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) NULL,
 CONSTRAINT [PK_Occupation] PRIMARY KEY NONCLUSTERED 
(
	[ID] ASC
)) ON [PRIMARY]

GO

/****** Object:  Table [Country]    Script Date: 08/29/2011 14:38:57 ******/

CREATE TABLE [Country](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[CountryName] [varchar](40) NULL,
	[Code] [varchar](20) NULL,
	[ISO] [varchar](20) NULL,
	[CallCode] [varchar](20) NULL,
 CONSTRAINT [PK_Country] PRIMARY KEY NONCLUSTERED 
(
	[ID] ASC
)) ON [PRIMARY]

GO

/****** Object:  Table [Registration]    Script Date: 08/29/2011 14:38:57 ******/
CREATE TABLE [Registration](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[FirstName] [varchar](40) NULL,
	[LastName] [varchar](40) NULL,
	[Email] [varchar](40) NULL,
	[Password] [varchar](20) NULL,
	[Country] [varchar](40) NULL,
	[ActivationKey] [varchar](20) NULL,
 CONSTRAINT [PK_Registration] PRIMARY KEY NONCLUSTERED 
(
	[ID] ASC
)) ON [PRIMARY]

/****** Object:  Table [Address]    Script Date: 08/29/2011 14:37:44 ******/
CREATE TABLE [Address](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Line1] [varchar](40) NULL,
	[Line2] [varchar](40) NULL,
	[Line3] [varchar](40) NULL,
	[City] [varchar](40) NULL,
	[County] [varchar](40) NULL,
	[PostCode] [varchar](40) NULL,
	[Country] [varchar](40) NULL,
	[AddressType] [varchar](20) NULL,
	[UserID] [int] NULL,
 CONSTRAINT [PK_Address] PRIMARY KEY NONCLUSTERED 
(
	[ID] ASC
)) ON [PRIMARY]

GO

/****** Object:  Table [UserDetail]    Script Date: 08/29/2011 14:37:44 ******/

CREATE TABLE [UserDetail](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[FirstName] [varchar](40) NULL,
	[LastName] [varchar](40) NULL,
	[Email] [varchar](40) NULL,
	[Password] [varchar](20) NULL,
	[Country] [varchar](40) NULL,
	[ContactNumber] [varchar](20) NULL,
	[Mobile] [varchar](20) NULL,
	[AddressID] [int] NULL,
	[DateOfBirth] [datetime] NULL,
	[Occupation] [varchar](40) NULL,
	[AccountEnabled] [bit] NULL,
 CONSTRAINT [PK_UserDetail] PRIMARY KEY NONCLUSTERED 
(
	[ID] ASC
)) ON [PRIMARY]

GO

CREATE TABLE [Listing]
(
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] Not NULL,
	[Title] [varchar](255) NULL,
	[NumberOfSpace] [int] NULL,
	[SpaceCategory] [varchar](20) NULL,
	[SpaceRestriction] [varchar](20) NULL,
	[IsPrivate] [bit] NULL default 1,
	[Daily] [bit] NULL default 1,
	[Weekly] [bit] NULL default 1,
	[Monthly] [bit] NULL default 1,
	[Annual] [bit] NULL default 1,
	[OnEventDays] [bit] NULL default 1,
	[Deposit] money null,
	[MinRentalPeriod] [int] NULL,
	[MinRentalPeriodUnit] [varchar](40) NULL,
	[FeatureID] [int] NULL,
	[AddressID] [int] NULL,
	[ContactNumber] [varchar](40) NULL,
	[SpaceDescription] [varchar](2000) NULL,
	[IsActive]  [bit] default 1,
	CONSTRAINT [PK_Listing] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)) ON [PRIMARY]

GO

CREATE TABLE [ListingPhoto](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[FileName] [varchar](50) NULL,
	[ListingID] [int] NULL,
	[IsPrimary] [bit] NULL,
	 CONSTRAINT [PK_ListingPhoto] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)
) ON [PRIMARY]

GO

CREATE TABLE [ListingPrice](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ListingID] int Null,
	[Price] [money] NULL,
	[PriceDuration] [varchar](20) NULL,
	[Vehicle] [varchar](20) NULL,
	[Bid] [money] null,
	 CONSTRAINT [PK_ListingPrice] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)
) ON [PRIMARY]

GO

CREATE TABLE [ListingFeature]
(
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Available247] [bit] NULL,
	[KeyReq] [bit] NULL,
	[CCTV] [bit] NULL,
	[Gated] [bit] NULL,
	[LocalTrain] [bit] NULL,
	[Lighted] [bit] NULL,
	[LocalBus] [bit] NULL,
	[Sheltered] [bit] NULL,
	[SecurityGuard] [bit] NULL	,
	 CONSTRAINT [PK_ListingFeature] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)
) ON [PRIMARY]

GO